New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Max encoder resolution supported #12
Comments
The Remora encoder software module runs in the base thread at 40kHz. The 2500 PPR would be too much for the software module to handle. 100PPR would be ok. Interesting to know about the QEI module and it's pins are available on the EXP1 header. Not sure about the capabilities of the hardware module. Would be an interesting experiment when time permits. |
Yea the doc sheet gives little info about the max rate and Google did not turn up much. I wonder how much more the hardware one can run at. |
So i was looking at your code for encoders and i noticed that it only has support for cha/b but no z index pulse. |
did some more quick google searches and seems there is a project with support for this very thing. So i went and ordered an encoder to play with this some more. |
Hi, thanks for sharing. The index pulse could be utilised with a Remora DigitalPin to expose it on the LinuxCNC side. The QEI module is a neat way to capture the encode but would need some work to get the info across to LinuxCNC. Porting the code to Mbed and then a wrapper module for Remora. I'm currently focused on stepper driver support but I'm keen to follow your progress on this one. |
My encoder came in but i am having issues setting up my HAL file #spindle DAC #Spindle encoder
Config on board |
Hi, firstly you will need to use the matching PRUencoder component for LinuxCNC. It takes in the raw-count from the firmware encoder module. Just like the normal encoder module you set the scale and the component will output position and velocity. https://github.com/scottalford75/Remora/tree/main/LinuxCNC/Components/PRUencoder I've got an example on my workshop PC for encoder feedback for position control using the module. I'll share that as a starting point. Give me 30min or so to get down to the workshop. BR Scott |
This would also be a great config to share once you have it working! |
Closed loop config example has just been pushed to Github. |
Okay, i am trying to wrap my head around the new config. Remora Process Value (PV) feedbacks addf PRUencoder.capture-position servo-thread (this just load the encoder module) Then i see in # Joint 0 setup And lastly i see in the ini file Sorry for alot of questions but i am a novice in Linuxcnc so i am learning as i go. But sometimes i feel the more i learn the less i know. |
Did a bit more looking into the source, is the remora encoder module only giving the raw count? |
The remora encoder module works the same way as the standard LinuxCNC encoder module but with the raw counts being performed in the controller board in firmware. Position and velocity are outputs. Looking at the spindle documentation it looks like the scaled position feedback goes to spindle.N.revs and the velocity feedback to spindle.N.speed-in. This is how it is also shown in the above example. Below is totally untested, but conceptually: loadrt PRUencoder names=spindle-encoder addf PRUencoder.capture-position servo-thread setp spindle-encoder.position-scale "your scale value" /# The spindle encoder position should be scaled such that spindle-revs increases by 1.0 for each rotation of the spindle in the clockwise (M3) direction. net spindle-index <= remora.input.6 => spindle.0.index-enable |
How do i define a pin to be pulled high? |
i get the error ./remora-xyz.hal:50: Pin 'spindle-encoder.veloctiy' does not exist |
Hi, sorry for the typo. Spelling of velocity. |
I can't belive I missed it. |
That's been on the TO DO list. The underlying pin driver has the capability already but it not exposed in the Json configuration or DigitalPin module as yet. |
fixing the spelling now i get another error Also i had to comment out net spindle-index <= remora.input.6 #=> spindle.0.index-enable I got this error |
Ok, my mistake. The standard linuxcnc encoder module and an index-enable IO as well that is meant to be connected to the spindle index-enable. The PRUencoder component will need to have this functionality. Let me have a look. BTW, I'm just testing the modifiers for inputs. Inverting, Open drain, pull up and pull down functionality now working on the test bench. I'll push the updates shortly. |
New update pushed to the repo, both source and firmware.bin. Input modifier functionality. In the Digital Pin Json config, modifiers are enabled by adding "Modifier": "Pull Up", Modifiers are: Invert, Open Drain, Pull Up, Pull Down, Pull None. |
Awesome. In my case the encoder needs a pull up on all logic pins. (currently being done via 3k resistors) Would a work around for the spindle encoder just to tinker around with at the moment be to use the RPI gpio to linux cnc? Any way for me to send you some beer money for all your hard work? |
Hi, should be an easy feature to add to the encoder module. Let me have a look. Thanks for the appreciation and offer. Beer money also helps buy components for testing etc to be able to keep adding features. My Paypal account is the same as my username @gmail.com |
Ok, I reworked the output pin modifier options to be at a lower level. This allows the encoder module to use it. I cannot test as I don't have an optical encoder. Can you test? Add the modifier to the encoder Json config: "Modifier": "Pull Up", Thanks Scott |
Seems to be working ish but not sure. Hmm it seems a 300ppr encoder may be too much. i have it connected to a 12V motor just to test and the spindle position counter seems to stop increase its count speed at a certain point as the motor goes faster. but without index working i dont know how many rpm it is. |
If it's only counting in one direction then is probably missing the A or B channel. The logic is designed to cope with a missed pulse and will count up by two on one channel. The encoder module runs at 40khz so will have a limit. The QEI module is probably the ultimate solution and needed feature for high speed counting. |
Okay that makes sense. |
Hi aaroncnc, I have added index functionality to the Remora encoder module and the PRUencoder component. Tested on the benchtop with a magnetic encoder. The encoder module will output the index position count for one SERVO_PERIOD along with the index pulse. In your HAL file you will need to
The Json config now has the ability to pass the index pin details, the physical pin and the input data bit.
|
I am havving issues installing the new PRUencoder looking at the code was this to be a comment? |
Oops, typo whilst cutting and pasting.
I'm just testing some more to make sure it's reliable. I'll re-push both
PRUencoder.c and firmware in a minute or so.
…On Sun, Apr 25, 2021 at 1:34 PM aaroncnc ***@***.***> wrote:
I am havving issues installing the new PRUencoder
When i run: Sudo halcompile --install PRUencoder.c
I get an error
In function export_encoder
265.2 phase undeclared
265.8 z undeclared
looking at the code was this to be a comment?
If so i changed 265 to /* phase-Z */
After doing that it installed.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#12 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGBMVIJR6W6UIFCU7SWDNEDTKOEUDANCNFSM4253CWIA>
.
|
Should i wait to flash the board? |
Just pushed the latest firmware to ensure the index pulse to LinucCNC is
long enough. Should be good to test now.
…On Sun, Apr 25, 2021 at 1:40 PM aaroncnc ***@***.***> wrote:
Should i wait to flash the board?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#12 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGBMVIM4AH2ZOFXVVZ66G5LTKOFMJANCNFSM4253CWIA>
.
|
Any chance you can post the snip of the hal file for the encoder? |
I was using it on an axis and tested homing on index. I don't have a spindle but the following might work. net encoder-count <= remora.PV.2 => spindle-encoder.raw_count |
How would one see if the pulse is working in the show hal configuration? |
Ok, for the config, that data bit is the remora.input."Data Bit" in your HAL config. Index Pin is the SKR pin your using for the Phase Z index.
For testing, you will either need to use halscope or use halshow to monitor the spindle-encoder.index-enable pin. The pulse is short so you will not see it when watching remora.input.i setp spindle-encode.index-enable and then watch this pin. It will go from high to low when the index pulse is detected. |
Okay that makes sense. |
Yes, having anther 8 inputs would be handy. There is room in the data packet, would just need to rework the code to be able to pack and decode two 8 bit bytes. |
So, for your spindle set-up. LinuxCNC at some point (spindle homing??) will request the encoder to index-enable to set the position to zero on the index pulse. I haven't looked into how the spindle does this or when. |
Also was doing some reading and am thinking that maybe my calculation for max encoder was off.
so it may be So maybe an encoder sub 100 ppr This may explain why even at what i thought was lower speeds i was losing counts... |
Okay so i tested again and you are correct it is enabled as i have it set in my hal and then once the pulse comes it turns off.
I have the system on my bench with a small motor that i can move with my hand and it works. Z axis is moving in step with the spindle. I have also noticed that spindle encoder position and spindle position always counts up no matter what way i spin the encoder. I was also testing out http://linuxcnc.org/docs/html/gcode/m-code.html#mcode:m19 |
Makes sense as the PWM value goes negative for reverse. What we'll need is a direction output for the VSD which is driven by the sign of the PWM value. Does your VSD have a direction pin available? Good to hear the encoder side of things is working! |
So my vfd is setup such that when feed 0-10v it goes counter clockwise. And when a pin is pulled high it goes clockwise. I have this in my Hal file but the dav value still goes negative despite there being a direction pin. Also is the encoder/ spindle position always to count up no matter what way it's spun? Is there a way to see more info to try to find out if the module is dropping pulses from the a/b channels. |
Ok, firstly something wrong with the encode if it's only counting up. One of the channels is not connected correctly. The Remora PWM module currently can only handle a positive value. Can you please share your HAL files? |
one of the resistor came off my encoder, this has been fixed and it is working. |
Question.
Im not sure one has an advantage over the other performance wise. Still finding myself losing count at not that high of speeds with my 300ppr. asked around and got sent a link that has this info https://www.forum.linuxcnc.org/38-general-linuxcnc-questions/34569-lathe-spindle-encoder-with-cheap-max-50-lpt-breakeout-board
This would work out to 13.33KHz safe max |
Here is a mbed lpc1768 module Spec sheet page 554 |
Hi, great to hear things are working and well done with the HAL config. And thanks for finding the Mbed QEI code. That will make things so much quicker to integrate into Remora. A simple wrapper should be easy to code. |
For your spindle PID I would use the LinuxCNC PID component. For 3D printer heater control I use PID on the LinuxCNC side. |
I got pid working on my system. |
Hi aaroncnc, I've developed and added the QEI module into Remora. Ready for testing. In the Remora config.txt the module is enabled with
Of course the PV[i] and Data Bit settings are as per your specific configuration. This should hopefully allow you to use your current encoder for higher speeds on your spindle. |
Awesome. I will see if I can start testing tomorrow or Monday. Side note I was looking into the chip and it's features and saw the dac but found on the skr1.4 the pos ref pin is not broken out but tied into the 3v line. Was thinking how awesome it would have been if it was broken out to a pad. Then a user could feed it a vref from a vfd and have another easy control option. But the only way to use it on a skr1.4 board would be to lift the leg of the pin and solder some fine coil wire. On a plus side my vfd has a pdm input so no need to mess with a pwm filters as a simple dac. Thus will make the pid control much better |
It's working. Tested to over 10k rpm |
Hi aaroncnc, looks like you had a channel not connected. But I see you've
tested to 10k RPM. Great to hear.
…On Mon, May 10, 2021 at 1:51 AM aaroncnc ***@***.***> wrote:
[image: 20210509_114430]
<https://user-images.githubusercontent.com/81981239/117578432-54eb9e80-b0bc-11eb-8002-a0036bb7e4ef.jpg>
Encoder count is jumping between 1 and 2 and never goes up.
Spindle speed also is not changing much 0.8 or so at all speeds.
Going back to the software encoder everything works.
So hardware is fine.
Any way to get the board to print more qem info via serial?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#12 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGBMVILL7FLYFYWJMSJQJILTM2VRFANCNFSM4253CWIA>
.
|
Yup I forgot I moved the pins off the dedicated ones. Question. |
So i am looking to add encoder support to my mill and was shopping around but before buy i had a few questions.
What would be the max supported PPR (pulse per rev) of the hardware.(skr 1.4 non turbo)
If my motor is running at 3,000rpm and i get a 2,500PPR encoder
3000(RPM)*2500(PPR)/60(convert to seconds) = 125,000 pulse a second.
Would that be to much for it to handle?
I know it may not be tested and i dont have very much experience.
I am looking at these BTW (https://www.aliexpress.com/item/32961497880.html?spm=a2g0o.productlist.0.0.3ae621a5ymVxfB&algo_pvid=c010e7f7-b79d-4248-8cf0-27db96f28711&algo_expid=c010e7f7-b79d-4248-8cf0-27db96f28711-5&btsid=0b0a556616184206137934196e3680&ws_ab_test=searchweb0_0,searchweb201602_,searchweb201603_
)
maybe 100PPR would be better?
3000(RPM)*100(PPR)/60(convert to seconds) =5,000 pulse a second
I see on the data sheet the chip has a dedicated Quadrature Encoder Interface and they are broken out as follows on a skr 1.4 board
A phase pin 1.20
B Phase pin 1.23
Z/index pin 1.24
The text was updated successfully, but these errors were encountered: